home *** CD-ROM | disk | FTP | other *** search
- Path: news.sprintlink.net!datalytics!usenet
- From: Rob Stewart <stew@datalytics.com>
- Newsgroups: comp.lang.c++
- Subject: Re: HELP ! Need a DELAY routine
- Date: Wed, 20 Mar 1996 11:18:06 -0500
- Organization: Datalytics, Inc
- Message-ID: <31502FBE.165F@datalytics.com>
- References: <4ihh45$css@aldebaran.sct.fr> <4ik551$14k@reader2.ix.netcom.com>
- NNTP-Posting-Host: 204.62.224.71
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (WinNT; I)
-
- John Lilley wrote:
- >
- > In article <4ihh45$css@aldebaran.sct.fr>, winter@worldnet.net says...
- > >
- > >I'm programming an emulator for an old computer. To make it run
- > >properly, I need a special routine in C to make a delay in ms.
- > >For example, I would like to make a 60ms delay, or a 20ms delay.
- > >How can I do this ? The delay() function is 1000% bugged.
- >
- > Be more specific. Which computer/compiler?
- >
- > john lilley
-
- In general, if you have a library routine or OS call you can
- make that returns time in seconds or some other resolution, you
- can call a designated loop repeatedly until ten times the timer
- routine's resolution has elapsed. You now have a basis for the
- number of times to call your delay loop for a given time delay.
- Using that basis, you can now calculate the number of times to
- call your delay routine to effect a specific delay.
-
- The idea is to ensure that the delay loop, which just loops a
- predetermined number of times, is called enough times that the
- aggregate calls consume the desired time. By calibrating the
- duration of the inner delay loop, you can make your outer delay
- routine accurate among various speed processors.
-
- The alternative, just looping 1000 times, for example, was a
- classic mistake of years ago. Programs that worked fine on a
- slow machine would run ridiculously fast on newer, faster
- computers.
-
- --
- Robert Stewart | My opinions are usually my own.
- Datalytics, Inc. | stew@datalytics.com
-